<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of PhotoController
 *
 * @author QuangKhoi
 */
class PhotoController {
    //put your code here
    public $model;
    
    public $view;
    
    public function __construct($model, $view) {
        $this->model = $model;
        $this->view = $view;
        
        
    }
    
    public function render($type, $page = 1, $date = '', $length = 12) {
        $position = ($page - 1) * $length;
        switch (strtoupper($type)) {
            case "FOLLOWING":
                $statuses = Status::getFollowingStatuses($position, $length);
                break;
            case "POPULAR":
                $statuses = Status::getPopularStatuses($position, $length, $date);
                break;
            case "EVERYONE":
                $statuses = Status::getEveryoneStatuses($position, $length, $date);
                break;
            case "DEBUTS":
                $statuses = Status::getDebutsStatuses($position, $length, $date);
                break;
        }
        $this->view->length = $length;
        $this->view->type = $type;
        $this->view->page = $page;
        $this->view->date = $date;
        $this->view->model = $this->model;
        $this->view->statuses = $statuses;
        $masterView = MasterView::getInstance();
        $masterView->view = $this->view;
        $masterView->error = $error;
    }
    
    public function displayPhoto($image) {
        $this->view->status = Status::withId(Status::getStatusId($this->model->id));
        $this->view->model = $this->model;
        $this->view->replies = Reply::getReplies($this->view->status->id);
        $masterView = MasterView::getInstance();
        $masterView->view = $this->view;
        $masterView->error = $error;
        $alias = str_replace(" ", '-', $this->model->title);
        if (substr($image, strlen($this->model->id) + 1) != $alias) {
            $this->view->model = null;
            return;
        }
    }
}

?>
